package com.hainatong.shiphelper.module.QSHE.adapter;

import com.hainatong.shiphelper.module.QSHE.entity.QSHEDetailBean;
import org.jetbrains.annotations.NotNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.hainatong.shiphelper.R;
import com.hainatong.shiphelper.databinding.ItemFileViewBinding;

public class QSHEFileAdapter extends BaseQuickAdapter<QSHEDetailBean, BaseDataBindingHolder<ItemFileViewBinding>>
{

    public QSHEFileAdapter()
    {
        super(R.layout.item_file_view);
    }

    @Override
    protected void convert(@NotNull BaseDataBindingHolder<ItemFileViewBinding> bindingHolder, QSHEDetailBean fileEntity)
    {
        ItemFileViewBinding binding = bindingHolder.getDataBinding();

        if( binding != null )
        {
            binding.tvFunTitle.setText( fileEntity.getFileName() );

            // doc   pdf  等
            if( fileEntity.getFileName().endsWith(".doc") )
            {
                Glide.with(getContext())
                        .load( R.mipmap.ic_file )
                        .into( binding.ivFunSub );
            }

            if( fileEntity.getFileName().endsWith(".pdf") )
            {
                Glide.with(getContext())
                        .load( R.mipmap.ic_pdf )
                        .into( binding.ivFunSub );
            }
        }
    }
}
